package exercises.Charpter9;

import java.util.Random;

interface Gamble{
	Boolean win();
}

interface GambleFactory{
	Gamble getGamble();
}

class Coin implements Gamble{

	@Override
	public Boolean win() {
		Random rand = new Random();
		boolean win = rand.nextBoolean();
		return win;
	}
}

class CoinFactory implements GambleFactory{

	@Override
	public Gamble getGamble() {
		return new Coin();
	}
}

class Dice implements Gamble{

	@Override
	public Boolean win() {
		Random rand = new Random();
		boolean win = rand.nextBoolean();
		return win;
	}
}

class DiceFactory implements GambleFactory{

	@Override
	public Gamble getGamble() {
		return new Dice();
	}
}

public class Nineteen {
	public static void playGamble(Gamble myGamble){
		if (myGamble.win())
			System.out.println("Win");
		else {
			System.out.println("Lose");
		}
	}
	
	public static void main(String[] args){
		playGamble(new Coin());
		playGamble(new Dice());
	}
}
